import request from '@/utils/request';

/**
 * 终端页面初始化
 * @param {Number} store_id 门店id
 */
export function TerminalInit (store_id) {
    return request({
        url: '/merchant_backend/merchantAdmin/terminal/display',
        method: 'GET',
        params: { store_id }
    });
}

/**
 * 终端页面分页
 * @param {Number} store_id 门店id
 * @param {Number} page 分页
 */
export function TerminalPage (store_id, page) {
    return request({
        url: '/merchant_backend/merchantAdmin/terminal/display',
        method: 'GET',
        params: { store_id, page }
    });
}

/**
 * 终端绑定
 * @param {Number} store_id 门店id
 * @param {Object} date 绑定参数
 */
export function bindTerminal (store_id, date) {
    const data = { device_category: date.category, store_id, device_sn: date.device_sn, device_id: date.device_id, remarks: date.remarks, pwd: date.pwd };
    return request({
        url: '/merchant_backend/merchantAdmin/terminal/binding',
        method: 'POST',
        data
    });
}

/**
 * 终端类别初始化
 */
export function bindTerminalInit () {
    return request({
        url: '/merchant_backend/merchantAdmin/terminal/category',
        method: 'GET'
    });
}

/**
 * 终端名称搜索
 * @param {Number} category_id 类别id
 */
export function bindTerminalDropInit (category_id) {
    return request({
        url: '/merchant_backend/merchantAdmin/terminal/dropdown',
        method: 'GET',
        params: { category_id }
    });
}

/**
 * 绑定终端门店初试化
 * @param {Number} store_id 门店id
 */
export function TerminalBindStoreInit (store_id) {
    return request({
        url: '/merchant_backend/merchantAdmin/terminal/category',
        method: 'GET',
        params: { store_id }
    });
}

/**
 * 绑定状态查询初始化
 * @param {Number} store_id 门店id
 */
export function bindStatusTerminalInit (store_id) {
    return request({
        url: '/merchant_backend/merchantAdmin/terminal/hornlist',
        method: 'GET',
        params: { store_id }
    });
}

/**
 * 解绑终端
 * @param {Number} bind_id 终端id
 */
export function TerminalFiedBind (bind_id) {
    return request({
        url: '/merchant_backend/merchantAdmin/terminal/relieve',
        method: 'DELETE',
        params: { bind_id }
    });
}

/**
 * 终端详情查看
 * @param {Number} bind_id 终端id
 */
export function TerminalList (bind_id) {
    return request({
        url: '/merchant_backend/merchantAdmin/terminal/detail',
        method: 'GET',
        params: { bind_id }
    });
}

/**
 * 绑定状态查询
 * @param {Number} store_id 门店id
 * @param {Object} date 查询参数
 */
export function bindStatusTerminalSearch (store_id, date) {
    return request({
        url: '/merchant_backend/merchantAdmin/terminal/hornlist',
        method: 'GET',
        params: { store_id, sn: date.sn }
    });
}

/**
 * 绑定状态查询分页
 * @param {Number} store_id 门店id
 * @param {Object} date 搜索参数
 * @param {Number} page 分页
 */
export function bindStatusTerminalPage (store_id, date, page) {
    return request({
        url: '/merchant_backend/merchantAdmin/terminal/hornlist',
        method: 'GET',
        params: { store_id, sn: date.sn, page }
    });
}

/**
 * 绑定状态查询设置音量
 * @param {Object} date 设置参数
 */
export function bindStatusTerminalVolumn (date) {
    const data = {
        uid: date.id,
        sn: date.sn,
        vol: date.value
    };
    return request({
        url: '/merchant_backend/merchantAdmin/terminal/postvol',
        method: 'POST',
        data
    });
}

/**
 * 绑定状态查询播报状态
 * @param {Number} uid 用户id
 * @param {Number} sn sn码
 */
export function bindStatusTerminalVolState (uid, sn) {
    return request({
        url: '/merchant_backend/merchantAdmin/terminal/getvol',
        method: 'GET',
        params: { uid, sn }
    });
}

/**
 * 支付消息历史初始化
 * @param {Number} store_id 门店id
 */
export function historyTerminalInit (store_id) {
    return request({
        url: '/merchant_backend/merchantAdmin/terminal/msglist',
        method: 'GET',
        params: { store_id }
    });
}

/**
 * 支付消息历史查询
 * @param {Number} store_id 门店id
 * @param {Object} date 查询参数
 */
export function historyTerminalSearch (store_id, date) {
    return request({
        url: '/merchant_backend/merchantAdmin/terminal/msglist',
        method: 'GET',
        params: { store_id, sn: date.sn }
    });
}

/**
 * 支付消息历史分页
 * @param {Number} store_id 门店id
 * @param {Object} date 查询参数
 * @param {Number} page 页码
 */
export function historyTerminalPage (store_id, date, page) {
    return request({
        url: '/merchant_backend/merchantAdmin/terminal/msglist',
        method: 'GET',
        params: { store_id, sn: date.sn, page }
    });
}
